<?php

namespace app\api\logic;

use app\common\model\Faq;
use app\api\logic\BaseLogic;

class FaqLogic extends BaseLogic
{
    /**
     * 获取FAQ列表（不分页）
     */
    public function getList(array $params = [])
    {
        $where = ['status' => 1];
        $fields = ['id', 'question', 'answer', 'weigh', 'createtime', 'updatetime'];
        $data = Faq::where($where)->field($fields)
            ->order('weigh', 'desc')
            ->order('id', 'desc')
            ->select();

        if ($data) {
            foreach ($data as $key => $value) {
                $data[$key]['createtime'] = $value['createtime'] ? date('Y-m-d H:i:s', $value['createtime']) : '';
                $data[$key]['updatetime'] = $value['updatetime'] ? date('Y-m-d H:i:s', $value['updatetime']) : '';
            }
        }
        return $data ? $data : [];
    }
} 